package com.sailfish.springbootdemo.dao.db5;

import com.sailfish.springbootdemo.pojo.db5.BoardProportion;
import com.sailfish.springbootdemo.pojo.db5.H3c08n082Castplateinformation;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.Date;
import java.util.List;

public interface H3c08n082CastplateinformationDao {

    @Results(id = "boardProportionResultMap", value = {
            @Result(column = "WF_ORUNID", property = "wfOrunid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "PID", property = "pid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "NH3C_PartNo", property = "nh3cPartno", jdbcType = JdbcType.VARCHAR),
            @Result(column = "NH3C_BoardName", property = "nh3cBoardname", jdbcType = JdbcType.VARCHAR),
            @Result(column = "NH3C_RevisionNo", property = "nh3cRevisionno", jdbcType = JdbcType.VARCHAR),
            @Result(column = "NH3C_BoLevel", property = "nh3cBolevel", jdbcType = JdbcType.VARCHAR),
            @Result(column = "NH3C_LOSSCONTROL", property = "nh3cLossControl", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_PrintedSheet", property = "nh3cPrintedSheet", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_LayersNo", property = "nh3cLayersNo", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_BoardLengthCM", property = "nh3cBoardLengthCM", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_BoardWidthCM", property = "nh3cBoardWidthCM", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_BoardThicknessMM", property = "nh3cBoardThicknessMM", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_MinApeInfo", property = "nh3cMinApeInfo", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_MaximumAspectRatio", property = "nh3cMaximumAspectRatio", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_Minbackdrillstub", property = "nh3cMinbackdrillstub", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_Minimpedance", property = "nh3cMinimpedance", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_Minviabackdrill2line", property = "nh3cMinviabackdrill2line", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_SurfaceTreatment", property = "nh3cSurfaceTreatment", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_SpecialProInfo", property = "nh3cSpecialProInfo", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_IsSpell", property = "nh3cIsSpell", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_Spell", property = "nh3cSpell", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_IsFULLPRESSFITBACKPLANE", property = "nh3cIsFullPressFitBackPlane", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_Ishipottest", property = "nh3cIsHipottest", jdbcType = JdbcType.VARCHAR),
            @Result(column = "nh3c_Minvia2line", property = "nh3cMinVia2line", jdbcType = JdbcType.VARCHAR),
    })
    @Select("<script>" +
            "select * from BPM_ISSUE_H3C08N082_CASTPLATEINFORMATION " +
            "<where>" +
            "<if test='productCode0301 != null '>" +
            "and NH3C_PartNo = #{productCode0301}  " +
            "</if>" +
            "<if test='boardVer != null '>" +
            "and NH3C_RevisionNo = #{boardVer}  " +
            "</if>" +
            "<if test='searchLayer != null '>" +
            "and nh3c_LayersNo like CONCAT('%',  #{searchLayer},'%')  " +
            "</if>" +
            "<if test='searchLossControl != null '>" +
            "and NH3C_LOSSCONTROL like CONCAT('%',  #{searchLossControl},'%')  " +
            "</if>" +
            "<if test='searchPrintedSheet != null '>" +
            "and nh3c_PrintedSheet like CONCAT('%',  #{searchPrintedSheet},'%')  " +
            "</if>" +
            "<if test='searchBoardName != null '>" +
            "and NH3C_BoardName like CONCAT('%',  #{searchBoardName},'%')  " +
            "</if>" +
            "<if test='searchLength != null '>" +
            "and nh3c_BoardLengthCM like CONCAT('%',  #{searchLength},'%')  " +
            "</if>" +
            "<if test='searchWidth != null '>" +
            "and nh3c_BoardWidthCM like CONCAT('%',  #{searchWidth},'%')  " +
            "</if>" +
            "<if test='searchThickness != null '>" +
            "and nh3c_BoardThicknessMM like CONCAT('%',  #{searchThickness},'%')  " +
            "</if>" +
            "<if test='searchMinApeInfo != null '>" +
            "and nh3c_MinApeInfo like CONCAT('%',  #{searchMinApeInfo},'%')  " +
            "</if>" +
            "<if test='searchMaximumAspectRatio != null '>" +
            "and nh3c_MaximumAspectRatio like CONCAT('%',  #{searchMaximumAspectRatio},'%')  " +
            "</if>" +
            "<if test='searchMinbackdrillstub != null '>" +
            "and nh3c_Minbackdrillstub like CONCAT('%',  #{searchMinbackdrillstub},'%')  " +
            "</if>" +
            "<if test='searchMinimpedance != null '>" +
            "and nh3c_Minimpedance like CONCAT('%',  #{searchMinimpedance},'%')  " +
            "</if>" +
            "<if test='searchMinviabackdrill2line != null '>" +
            "and nh3c_Minviabackdrill2line like CONCAT('%',  #{searchMinviabackdrill2line},'%')  " +
            "</if>" +
            "<if test='searchSurfaceTreatment != null '>" +
            "and nh3c_SurfaceTreatment like CONCAT('%',  #{searchSurfaceTreatment},'%')  " +
            "</if>" +
            "<if test='searchSpecialProInfo != null '>" +
            "and nh3c_SpecialProInfo like CONCAT('%',  #{searchSpecialProInfo},'%')  " +
            "</if>" +
//            "<if test=' != null '>" +
//            "and  like CONCAT('%',  #{},'%')  " +
//            "</if>" +
            "</where>" +
            "</script>")
    List<H3c08n082Castplateinformation> getByNameAndVer(@Param("productCode0301") String productCode0301, @Param("boardVer") String boardVer,
                                                  @Param("searchLayer") String searchLayer, @Param("searchLossControl") String searchLossControl,
                                                  @Param("searchPrintedSheet") String searchPrintedSheet, @Param("searchPinbanfangshi") String searchPinbanfangshi,
                                                  @Param("searchBoardName") String searchBoardName, @Param("searchLength") String searchLength,
                                                  @Param("searchWidth") String searchWidth, @Param("searchThickness") String searchThickness,
                                                  @Param("searchMinApeInfo") String searchMinApeInfo, @Param("searchMaximumAspectRatio") String searchMaximumAspectRatio,
                                                  @Param("searchMinbackdrillstub") String searchMinbackdrillstub, @Param("searchMinimpedance") String searchMinimpedance,
                                                  @Param("searchMinviabackdrill2line") String searchMinviabackdrill2line, @Param("searchSurfaceTreatment") String searchSurfaceTreatment,
                                                  @Param("searchSpecialProInfo") String searchSpecialProInfo);

    @Select("<script>" +
            "select t3.NH3C_FOREIGNASSMAN " +
            "from (" +
            "  select t1.NH3C_PRINTBOCODING, t2.NH3C_FOREIGNASSMAN" +
            "  from BPM_ISSUE_H3C08N082_MAIN t1 " +
            "  left join IBPM_h3c08n082_factory t2 on t1.item_id = t2.ITEM_ID " +
            ") t3 " +
            "left join BPM_ISSUE_H3C08N082_CASTPLATEINFORMATION t4 on t3.NH3C_PRINTBOCODING = t4.NH3C_PartNo " +
            "<where>" +
            "<if test='productCode0301 != null'>" +
            "and t3.NH3C_PRINTBOCODING = #{productCode0301} " +
            "</if>" +
            "</where>" +
            "</script>")
    List<String> getForeignAssmanByProductCode(@Param("productCode0301") String productCode0301);
}
